$.extend(planner.drop, {
    ui:
    {
        init: function() {
            console.log("planner.drop.ui.init(): id: " + planner.drop.dropid + " p: " + planner.drop.player);
            $(".post").hide();

            if (planner.drop.dropid)
            {
                console.log(">");
                if (planner.drop.player == "")
                {
                    $("#enterid").show();
                }
            }
            else
            {
                $("#newdrop").show();
            }
        },
        setup: function ()
        {
            console.log("planner.drop.ui.setup()");
            planner.drop.ui.setup_site_menu();
            planner.drop.ui.setup_configure_menu();
            
            $("#btnLeaveDrop").click(function(event) {
                console.log("#btnLeaveDrop_click");
                
                planner.server.post_mech( 
                    { players: planner.mech.player, a: "x" }, 
                    function(data) { location.href='/'; },
                    function() { location.href='/';},
                    true
                );
            });
            
            $( "#btnLeaveDrop" ).tooltip({ show: { delay: 1000 } });


            setTimeout( planner.roster.ui.auto_update, 1000);
        },
        
        update: function()
        {
            console.log("planner.drop.ui.update()");
            planner.mech.ui.update();
            if ( planner.roster.ui.is_visible() )
                planner.roster.ui.update(function(){ $("#roster").show(); $("#rostercontent").show(duration=0); });
        },
        
        remove_selections: function ()
        {
            console.log("planner.drop.ui.remove_selections()");
            $(".cell-roster-grid").removeClass("gradient");
            $(".row-roster-table").removeClass("gradient");
            $(".row-garage-table").removeClass("gradient");
            $(".cell-garage-grid").removeClass("gradient");
            $(".row-roster-table").css("font-weight", "normal");
            $(".cell-roster-grid").css("border", "");
            $(".cell-roster-grid").css("margin", "6px");
        },
        select_div: function(element, gradient, border)
        {
            console.log("planner.drop.ui.select_div()");
            if (gradient) {
                element.addClass("gradient");//code
            }
            
            if ( border ) {
                //element.css("cursor", "pointer");
                element.css("border", "solid #ccc 2px");
                element.css("margin", "4px");
            }
            
            element.css("font-weight", "bold");
        },
        deselect_div: function(element, gradient, border)
        {
            console.log("planner.drop.ui.deselect_div()");
            if (gradient) {
                element.removeClass("gradient");
            }
            
            if ( border ) {
                //element.css("cursor", "default");
                element.css("border", "none");
                element.css("margin", "6px");
            }
            
            element.css("font-weight", "normal");
        },
        toggle_selection: function(element)
        {
            console.log("planner.drop.ui.toggle_selection(): ", element);
            if ( element.hasClass("gradient") )
            {
                console.log("planner.drop.ui.toggle_selection: selected");
                planner.drop.ui.deselect_div( element, true, false );
            }
            else
            {
                console.log("planner.drop.ui.toggle_selection: not selected");
                planner.drop.ui.select_div( element, true, false );
            }
            
            planner.roster.ui.set_button_state();
        }
    },
    leader: function()
    {
        console.log("planner.drop.leader()");
        l = "";
        
        $.each(planner.roster.mechs, function(i, mech) {
            if ( mech.starter )
                l = planner.drop.player;
        });
        
        return l;
    },
});
